//
//  SandBoxHandler.m
//  UI15_SandBox_NSFiledManager_NSFileHandler
//
//  Created by 岁变 on 16/3/29.
//  Copyright © 2016年 岁变. All rights reserved.
//

#import "SandBoxHandler.h"

@implementation SandBoxHandler

#pragma mark - Creaing and Init

+ (instancetype)sandBoxHandler {
    
    SandBoxHandler *sand = [[SandBoxHandler alloc] init];
    
    return sand;
    
}




#pragma mark - path

+ (NSString *)saveInDocumentWith:(NSString *)name {
    
    return  [[SandBoxHandler pathOfDocuments] stringByAppendingPathComponent:name];
    
}


+ (NSString *)pathOfDocuments {
    
    return  [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
    
}


/** 获取APP的 SandBox 路径 */
- (NSString *)pathOfAppSandBox {
    
    //核心API: 函数 NSHomeDirectory
    
    return NSHomeDirectory();
    
}

/** 获取Documents 路径 */

- (NSString *)pathOfDocuments {
    
    //核心API: NSSearchPath...
    
    return [SandBoxHandler pathOfDocuments];
}



/** 获取 Tmp 路径 */

- (NSString *)pathOfTemp {
    
    //Core API
    return  NSTemporaryDirectory();
}


/** 获取 Library 路径 */

- (NSString *)pathOfLibrary {
    
    return [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) lastObject];
    
}


/** 获取 Caches 路径 */

- (NSString *)pathOfCaches {
    
    return [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
    
}


/** 获取 Preferences 路径 */

- (NSString *)pathOfPreferences {
    
    //拼接字符串
    //return [[self pathOfLibrary] stringByAppendingString:@"/Preferences"];
    
    return [[self pathOfLibrary] stringByAppendingPathComponent:@"preferences"];
    
}

/** 获取 APP 包 路径 */

- (NSString *)pathOfAppBundle {
    
   return [NSBundle mainBundle].resourcePath;
    
}







@end
